package com.icehand.utils.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.Properties;

public class SystemConstant {
    private static final Logger LOGGER = LoggerFactory.getLogger(SystemConstant.class.getName());
    private static Properties config;

    private static void loadConfig() {
        if (config == null) {
            config = new Properties();
            ClassLoader loader = Thread.currentThread().getContextClassLoader();
            try {
                config.load(loader.getResourceAsStream("config.properties"));
            } catch (IOException e) {
                e.printStackTrace();
                LOGGER.error(e.getMessage());
            }
        }
    }

    public static String getConfig(String key)  {
        if (config == null) {
            loadConfig();
        }
        return config.getProperty(key);
    }
}
